package com.zhang;

import cn.hutool.core.util.IdUtil;
import com.google.gson.Gson;
import com.zhang.entity.Node;

import java.util.HashMap;

/**
 * User: 张
 * Date: 2024-11-27
 * Time: 14:12
 * Description:
 */

public class test5 {
    public static void main(String[] args) {
        HashMap<String, String> map = null;
        map = new HashMap<>();
        map.put("--red","1");
        map.put("--green","0");
        map.put("--yellow","0");
        map.put("--brightness","80");
        Node root = new Node(IdUtil.fastSimpleUUID(), "machine", "", "control_light", map);

        map = new HashMap<>();

        map.put("sleep","2000");
        Node node = new Node(IdUtil.fastSimpleUUID(), "system", "", "sleep", map);

        map = new HashMap<>();
        map.put("--red","1");
        map.put("--green","0");
        map.put("--yellow","0");
        map.put("--brightness","80");
        Node node1 = new Node(IdUtil.fastSimpleUUID(), "machine", "", "control_light", map);
        node.addChild(node1);
        root.addChild(node);
        root.addChild(root);

        Gson gson = new Gson();
        System.out.println(gson.toJson(root));

        reduce(root);
        int address = System.identityHashCode(root);
        System.out.println(Integer.toHexString(address));

    }

    public static void reduce(Node node){
        int address = System.identityHashCode(node);
        System.out.println(Integer.toHexString(address));
    }
}
